
#include "tests/test-utils.h"

namespace l8
{

static inline char conv_to_char(byte b)
{
    if (b < ' ' || b > 128)
    {
        return '.';
    }

    return (char)b;
}

void print_buf(byte * buf, bool add_space, size_t size, const char * buf_name, FILE * out)
{
    fprintf(out, "%s:", buf_name);

    const char * fmt_str = add_space ? "%02X " : "%02X";

    //char hex_str[17];
    //size_t b = 0;

    for (size_t i = 0; i < size; ++i)
    {
        if (!(i & 0x0f))
        {
            fprintf(out, "\n\t");
        }

        fprintf(out, fmt_str, (byte)buf[i]);

        //hex_str[b++] = conv_to_char((byte)buf[i]);
    }
}


} // namespace l8
